home *** CD-ROM | disk | FTP | other *** search
- /*(((HaHa)))*/
-
- /*
- ** $VER: bracket.rexx 1.0 (12.11.94) written by Robert Brandner
- **
- ** Finds corresponding bracket
- **
- ** Das geht nicht sehr gut in ARexx !
- */
-
- /* enable return codes */
-
- OPTIONS RESULTS
-
- TRACE RESULTS
-
- /* is PolyEd out there ? */
-
- if ~SHOW("Ports", "POLYED.1") then do
- say "Please start PolyEd before running this program."
- exit
- end
-
- ADDRESS POLYED.1.1
-
-
- 'GETCURSORPOS STEM CPOS.' /* position in CPOS.LINE and CPOS.COLUMN */
- 'GETCHAR VAR C'
-
- OPENING = '([{<'
- CLOSING = ')[}>' /* same order! */
-
- OP = pos(C, OPENING)
- CL = pos(C, CLOSING)
-
- if OP=0 & CL=0 then exit 10 /* not a bracket */
-
- /* search forward for a closing bracket */
- if OP>0 then do
- 'CURSOR RIGHT' /* move past bracket so that we don't find it again */
- OPCHAR = substr(OPENING, OP, 1)
- CLCHAR = substr(CLOSING, OP, 1)
- LEVEL=1
- do while LEVEL > 0
- /* Find next occurence of opening and closing bracket */
-
- FIND NEXT OPCHAR
- if RC > 0 then break /* not found! */
-
- 'GETCURSORPOS STEM OPPOS.'
- 'GOTOLINE' CPOS.LINE
- 'GOTOCOLUMN' CPOS.COLUMN
-
- FIND NEXT CLCHAR
- if RC > 0 then break /* not found! */
- 'GETCURSORPOS STEM CLPOS.'
-
-
- if (OPPOS.LINE < CLPOS.LINE) | ((OPPOS.LINE = CLPOS.LINE) & (OPPOS.COLUMN < CLPOS.COLUMN)) then
- do
- LEVEL = LEVEL+1
- CPOS.LINE = OPPOS.LINE
- CPOS.COLUMN = OPPOS.COLUMN
- say CPOS.LINE
- say CPOS.COLUMN
- end
- else
- do
- LEVEL = LEVEL-1
- CPOS.LINE = CLPOS.LINE
- CPOS.COLUMN = CLPOS.COLUMN
- end
-
- 'GOTOLINE' CPOS.LINE
- 'GOTOCOLUMN' CPOS.COLUMN
- end
- end
-
- /* The End */
-
-